package cn.sc.allinpay.allfavour.business.saledetail;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

import cn.pai.mvp.callback.MpCallBack;
import cn.sc.allinpay.allfavour.base.connect.http.AppRequest;
import cn.sc.allinpay.allfavour.base.connect.http.RequestManager;
import cn.sc.allinpay.allfavour.base.model.BaseModel;
import cn.sc.allinpay.allfavour.business.common.data.SaleCouponData;

/**
 * 售券详情
 * author：pany
 * on 2017/12/5 14:44
 */
public class SaleDetailModel extends BaseModel {

    /**
     * 创建营销活动订单
     *
     * @param amt
     */
    public void reqMarketCreateOrder(String amt, final MpCallBack<String, String> mpCallBack) {
//        RequestManager.reqMarketCreateOrder(amt, new OkSocket.OnResponse() {
//            @Override
//            public void onResponse(String resp) {
//                if (!TextUtils.isEmpty(resp)) {
//                    JSONObject respJson = JSON.parseObject(resp);
//                    if ("SUCCESS".equals(respJson.getString("return_code"))) {
//                        String orderId = respJson.getJSONObject("response").getString("order_id");
//                        mpCallBack.onSuccess(orderId);
//                    } else {
//                        mpCallBack.onFailure(null, respJson.getString("return_msg"));
//                    }
//                }
//            }
//
//            @Override
//            public void onError(String msg) {
//                mpCallBack.onFailure(null, msg);
//            }
//        });
    }

    /**
     * 售券订单接口
     *
     * @param orderNo    订单号
     * @param txnAmt     支付金额
     * @param txnType    字符类型
     * @param saleDatas  售券列表
     * @param mpCallBack
     */
    public void reqSaleCoupon(String orderNo, String txnAmt, String txnType, List<SaleCouponData> saleDatas, final MpCallBack<JSONObject, String> mpCallBack) {
        RequestManager.reqSaleCoupon(orderNo, txnAmt, txnType, saleDatas, new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                mpCallBack.onSuccess(response);
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }
}
